package mvc;

import java.util.*;
import java.sql.*;

public class FullNews {
	
boolean prev = false;
boolean next = false;
String prevs = "";
String nexts = "";
NewsPost post;
		       
public FullNews(DBconn db,String id) throws SQLException
{

	db.sqlQuery("SELECT person, firstname, lastname, email, news_date,news_id,isadmin, topic,news_text FROM person,news where news_id="+id+" and username = person");
		
	if(db.next()){	
		post = new NewsPost(db.getString("person"),
							db.getString("firstname"),
							db.getString("lastname"),
							db.getString("email"),
							db.getString("news_text"),
							db.getString("news_date"),
							db.getString("news_id"),
							db.getString("topic"));						
						
	
	db.sqlQuery("select news_id from news where news_id > "+id+" order by news_id desc limit 1");
	
	if(db.next()){
		prev = true;
		prevs = db.getString("news_id");
	}
	
	db.sqlQuery("select news_id from news where news_id < "+id+" order by news_id desc limit 1");
	
	if(db.next()){
		next = true;
		nexts = db.getString("news_id");
	}
	
}else{	
	post = new NewsPost("","","","","","","","");
}
}
		
public NewsPost getPost() { return post; }

public boolean isPrev() { return prev; }

public boolean isNext() { return next; }

public String getPrevs() { return prevs; }

public String getNexts() { return nexts; }
	
}